import Vue from 'vue'
import Router from 'vue-router'
import context from '../main.js'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)
export const constantRouterMap = [
  {path: '/login', component: _import('login/index'), hidden: true},
  {path: '/404', component: _import('404'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard', component: _import('dashboard/index')
    }]
  }
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})



export const asyncRouterMap = [
  /*  {
      path: '/system',
      component: Layout,
      redirect: '/system/article',
      name: '功能模块',
      meta: {title: '功能模块', icon: 'tree'},
      children: [
        {
          path: 'article',
          name: '文章',
          component: _import('article/article'),
          meta: {title: '文章', icon: 'example'},
          menu: 'article'
        },
      ]
    },*/
  {
    path: '/teacher',
    component: Layout,
    redirect: '/teacher/list',
    name: '讲师管理',
    meta: {title: '讲师管理', icon: 'teacher'},
    children: [
      {
        path: 'list',
        name: '讲师',
        component: _import('teacher/list'),
        meta: {title: '讲师', icon: 'teacher'},
        menu: 'teacher'
      }
    ]
  },
  {
    path: '',
    component: Layout,
    redirect: '/course',
    name: '课程',
    meta: {title: '课程', icon: 'course'},
    children: [
      {
        path: 'course',
        name: '录播课列表',
        component: _import('course/vod/list'),
        meta: {title: '录播课列表', icon: 'list'},
        menu: 'course',
      }, {
        path: 'course/courseInfo',
        name: '添加录播课',
        component: _import('course/vod/courseInfo'),
        meta: {title: '添加录播课', icon: 'add'},
        hidden: true,
        menu: 'course',
        // menu: 'courseInfo',
      }, {
        path: 'course/courseInfo/:id',
        name: '编辑录播课',
        component: _import('course/vod/courseInfo'),
        meta: {title: '编辑录播课', noCache: true},
        hidden: true,
        menu: 'course',
        // menu: 'courseInfo',
      }
      , {
        path: 'course/chapter/:id',
        name: '编辑章节',
        component: _import('course/vod/chapter'),
        meta: {title: '编辑章节'},
        hidden: true,
        menu: 'chapter',
      }, {
        path: 'course/publish/:id',
        name: '发布课程',
        component: _import('course/vod/publish'),
        meta: {title: '发布课程'},
        menu: 'publish',
        hidden: true,
      },{
        path: 'course/vod-commont/:id',
        name: '课程评论',
        component: _import('course/vod/vod-commont'),
        meta: {title: '发布课程'},
        menu: 'course',
        hidden: true,
      }
      , {
        path: 'article',
        name: '图文',
        component: _import('course/article/list'),
        meta: {title: '图文', icon: 'article'},
        menu: 'article'
      }
      , {
        path: 'article/edit',
        name: '添加图文',
        component: _import('course/article/edit'),
        meta: {title: '添加图文'},
        menu: 'article',
        hidden: true
      },
      , {
        path: 'article/edit/:id',
        name: '编辑图文',
        component: _import('course/article/edit'),
        meta: {title: '编辑图文'},
        menu: 'article',
        hidden: true
      },
      {
        path: 'article/category',
        name: '图文分类',
        component: _import('course/article/category'),
        meta: {title: '图文分类'},
        menu: 'article',
        hidden: true
      },
      {
        path: 'learningpath',
        name: '学习路径',
        component: _import('course/path/list'),
        meta: {title: '学习路径',icon: 'path'},
        menu: 'path'
      },
      {
        path: 'learningpath/category',
        name: '路径分类',
        component: _import('course/path/category'),
        meta: {title: '路径分类'},
        menu: 'path',
        hidden: true
      }
      , {
        path: 'learningpath/edit',
        name: '添加路径',
        component: _import('course/path/edit'),
        meta: {title: '添加路径'},
        menu: 'path',
        hidden: true
      }, {
        path: 'learningpath/edit/:id',
        name: '编辑路径',
        component: _import('course/path/edit'),
        meta: {title: '编辑路径'},
        menu: 'path',
        hidden: true
      },
      {
        path: 'learningpath/step/:id',
        name: '路径步骤',
        component: _import('course/path/stepList'),
        meta: {title: '路径步骤'},
        menu: 'path',
        hidden: true
      },
      {
        path: 'learningpath/stepedit',
        name: '添加步骤',
        component: _import('course/path/stepEdit'),
        meta: {title: '添加步骤'},
        menu: 'path',
        hidden: true
      },
      {
        path: 'learningpath/stepedit/:id',
        name: '编辑步骤',
        component: _import('course/path/stepEdit'),
        meta: {title: '编辑步骤'},
        menu: 'path',
        hidden: true
      },
      {
        path: 'learningpath/step/relation/:id',
        name: '学习步骤关联',
        component: _import('course/path/relation'),
        meta: {title: '学习步骤关联'},
        menu: 'path',
        hidden: true
      }, {
        path: 'learningpath/relation/edit',
        name: '添加课程',
        component: _import('course/path/relationEdit'),
        meta: {title: '添加课程'},
        menu: 'path',
        hidden: true
      }, {
        path: 'learningpath/relation/edit/:id',
        name: '编辑课程',
        component: _import('course/path/relationEdit'),
        meta: {title: '编辑课程'},
        menu: 'path',
        hidden: true
      },
    ],

  },
  {
    path: '/subject',
    component: Layout,
    redirect: '/subject/list',
    name: '录播课分类',
    meta: {title: '录播课分类', icon: 'tree'},
    children: [
      {
        path: 'list',
        name: '分类列表',
        component: _import('subject/list'),
        meta: {title: '分类列表', icon: 'list'},
        menu: 'subject'
      }, {
        path: 'subjectExcel',
        name: '批量添加',
        component: _import('subject/subjectExcel'),
        meta: {title: '批量添加', icon: 'add'},
        menu: 'subjectExcel'
      }
    ]
  },
  {
    path: '/log',
    component: Layout,
    redirect: '/log/list',
    name: '日志',
    meta: {title: '日志', icon: 'log'},
    children: [
      {
        path: 'list',
        name: '系统日志',
        component: _import('log/list'),
        meta: {title: '系统日志', icon: 'log'},
        menu: 'log'
      },{
        path: 'optList',
        name: '操作日志',
        component: _import('log/optLog'),
        meta: {title: '操作日志', icon: 'optlog'},
        menu: 'log'
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/list',
    name: '订单',
    meta: {title: '订单', icon: 'order'},
    children: [
      {
        path: 'list',
        name: '订单',
        component: _import('order/list'),
        meta: {title: '订单', icon: 'order'},
        menu: 'order'
      }
    ]
  },
  {
    path: '/member',
    component: Layout,
    redirect: '/member/list',
    name: '学员',
    meta: {title: '学员', icon: 'member'},
    children: [
      {
        path: 'list',
        name: '学员',
        component: _import('member/list'),
        meta: {title: '学员', icon: 'member'},
        menu: 'member'
      }
    ]
  },
  {
    path: '/site',
    component: Layout,
    redirect: '/site/banner/list',
    name: '站点管理',
    meta: {title: '站点管理', icon: 'system'},
    children: [
      {
        path: 'banner/list',
        name: 'banner列表',
        component: _import('site/banner/list'),
        meta: {title: 'banner列表', icon: 'list'},
        menu: 'banner'
      }, {
        path: 'dict/index',
        name: '系统配置',
        component: _import('site/dict/index'),
        meta: {title: '系统配置', icon: 'system'},
        menu: 'dict'
      },
      {
        path: 'dict/config',
        name: '配置项',
        component: _import('site/dict/config'),
        meta: {title: '配置项', icon: 'system'},
        menu: 'dict',
        hidden: true
      }
    ]
  },
  {
    path: '/statistics',
    component: Layout,
    redirect: '/statistics/chart',
    name: '统计',
    meta: {title: '统计', icon: 'tree'},
    children: [
      {
        path: 'chart',
        name: '图表统计',
        component: _import('statistics/chart'),
        meta: {title: '图表统计', icon: 'statistics'},
        menu: 'statistics'
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/',
    name: '用户权限',
    meta: {title: '用户权限', icon: 'table'},
    children: [
      {
        path:'permission',name:'权限菜单',component: _import('user/permission'),meta:{title:'权限菜单', icon: 'table'},menu: 'role'
      },
      {
        path: '', name: '用户列表', component: _import('user/user'), meta: {title: '用户列表', icon: 'user'}, menu: 'user'
      },
      {
        path: 'role',name: '权限管理',component: _import('user/role'),meta: {title: '权限管理', icon: 'password'},menu: 'role'
      },
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]
